package com.abo.yaas.view.widgets;

import com.abo.yaas.i18n.Lang;
import com.abo.yaas.i18n.LocaleChangeListener;
import com.abo.yaas.i18n.LocaleChangedEvent;
import com.vaadin.ui.Panel;

@SuppressWarnings("serial")
public class LocaleSensitivePanel extends Panel implements LocaleChangeListener {

    private String translationId = "";    
    
    public LocaleSensitivePanel(String translationId) {
        super(Lang.getMessage(translationId));
        this.translationId = translationId;
    }
    
    
    @Override
    public void localeChanged(LocaleChangedEvent event) {
        setCaption(Lang.getMessage(translationId));
    }

    @Override
    public void attach() {
        super.attach();
        Lang.addListener(this);
    }
    
    @Override
    public void detach() {
        super.detach();
        Lang.removeListener(this);
    }
}
